package protein

const testVersion = 1

var codonMap = map[string]string{
	"AUG": "Methionine",
	"UUU": "Phenylalanine",
	"UUC": "Phenylalanine",
	"UUA": "Leucine",
	"UUG": "Leucine",
	"UCU": "Serine",
	"UCC": "Serine",
	"UCA": "Serine",
	"UCG": "Serine",
	"UAU": "Tyrosine",
	"UAC": "Tyrosine",
	"UGU": "Cysteine",
	"UGC": "Cysteine",
	"UGG": "Tryptophan",
	"UAA": "STOP",
	"UAG": "STOP",
	"UGA": "STOP",
}

func FromCodon(input string) string {
	if ele, ok := codonMap[input]; ok {
		return ele
	}

	return ""
}

func FromRNA(input string) (expected []string) {
	countMap := map[string]int{}
	count := len(input) / 3

	for i := 0; i < count; i++ {
		codon := FromCodon(input[i*3 : i*3+3])

		if _, ok := countMap[codon]; !ok && codon != "" && codon != "STOP" {
			expected = append(expected, codon)
			countMap[codon] = 1
		}

		if len(expected) >= 3 {
			break
		}
	}

	return
}
